home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 June: Reference Library / Dev.CD Jun 96 RL / Dev.CD Jun 96 RL.toast / Technical Documentation / develop / develop Issue 23 / develop Issue 23 code / ProjectDrag 1.1b8 / Sources / ProjectDrag Sources / Cancel.c next >
Encoding:
C/C++ Source or Header  |  1995-07-25  |  2.3 KB  |  91 lines  |  [TEXT/MPS ]

  1. /* Cancel.c: Cancel applet for ProjectDrag.
  2.  *
  3.  * A set of applets for drag and drop source control by Tim Maroney.
  4.  * See develop, issue 23 for details.
  5.  *
  6.  * Built on DropShell by Leonard Rosenthol, Stephan Somogyi, and Marshall Clow,
  7.  * and using the MoreFiles utilities by Jim Luther.
  8.  *
  9.  * This software is free, but don't modify and redistribute it without
  10.  * changing the status window to indicate your name and your changes!
  11.  */
  12.  
  13.  
  14. #include "DSUserProcs.h"
  15. #include "PDDialogs.h"
  16. #include "PDUtilities.h"
  17. #include "FileCancel.h"
  18. #include "TasksAndErrors.h"
  19.  
  20.  
  21. void CancelFile(FSSpec *file, Boolean doingFolder);
  22.  
  23.  
  24. /* This routine is called for each file passed in the ODOC event. */
  25.  
  26. pascal void OpenDoc ( FSSpecPtr myFSSPtr, Boolean opening, Handle userDataHandle )
  27. {
  28. #pragma unused ( opening )
  29. #pragma unused ( userDataHandle )
  30.  
  31.     ProcessFileOrFolder(myFSSPtr, CancelFile, ProcessFolder);
  32. }
  33.  
  34.  
  35. void CancelFile(FSSpec *file, Boolean doingFolder)
  36. {
  37.     OSErr err;
  38.     CKIDHandle theCKID;
  39.     
  40.     /* get the CKID */
  41.     TaskStart(2001, 2, file->name, NULL, NULL, NULL);  /* inspecting */
  42.     err = ExtractCKID(file, &theCKID);
  43.     if (err != noErr)
  44.     {
  45.         if (!doingFolder)
  46.             RaiseErrorString(kProjectDragStrings, kCantGetCKID, file->name,
  47.                              NULL, NULL, NULL);
  48.         return;
  49.     }
  50.     TaskDone();
  51.     
  52.     TaskStart(2001, 1, file->name, NULL, NULL, NULL);  /* canceling */
  53.     
  54.     /* is the file already checked out or MRO? */
  55.     if ((*theCKID)->modifyReadOnly || (*theCKID)->writeable)
  56.     {
  57.         /* confirm the discard */
  58.         if (!ResTextYesNo(kProjectDragStrings, kConfirmDiscardChanges, file->name, NULL, NULL, NULL))
  59.         {
  60.             DisposeHandle((Handle)theCKID);
  61.             RaiseErrorNumber(userCanceledErr);
  62.             return;
  63.         }
  64.     }
  65.     else if (!doingFolder)
  66.     {
  67.         /* it doesn't seem to be checked out, but we can try to cancel it anyway
  68.          *  -- after all, we may have lost the checked-out copy...
  69.          */
  70.         if (!ResTextYesNo(kProjectDragStrings, kCancelEvenThoughNotCheckedOut, file->name, NULL, NULL, NULL))
  71.         {
  72.             DisposeHandle((Handle)theCKID);
  73.             RaiseErrorNumber(userCanceledErr);
  74.             return;
  75.         }
  76.     }
  77.     
  78.     err = FileCancel(file, theCKID);
  79.     DisposeHandle((Handle)theCKID);
  80.     if (err == noErr) TaskDone();
  81. }
  82.  
  83.  
  84. void DoFileMenu(short itemID)
  85. {
  86.     if ( itemID == 1 )
  87.         SelectFile();        // call file selection userProc
  88.     else
  89.         SendQuitToSelf();    // send self a 'quit' event
  90. }
  91.